//
//  OthersListenReusableView.swift
//  TianTianBiTing
//
//  Created by Gox mac 2 on 2018/12/21.
//  Copyright © 2018 Gox_WallyDiao. All rights reserved.
//

import UIKit
protocol OthersListenReusableViewDelegate:NSObjectProtocol {
    func OthersListenReusableViewClick(id:Int, name:String)
}
typealias OthersListenHeaderMoreBtnClick = () ->Void

class OthersListenReusableView: UICollectionReusableView {
    var delegate : OthersListenReusableViewDelegate?
    var id:Int = 0
    var leftLabel = UILabel()
    let rightBtn = UIButton()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
    }
    
    func setUpUI() {
        self.leftLabel.text = ""
        self.leftLabel.textColor = BlackBackColor
        self.leftLabel.font = Font_Medium(17)
        self.leftLabel.frame = FRAME_CGFloat(15, 15, 100, 25)
        self.leftLabel.textAlignment = .left
        self.addSubview(self.leftLabel)
        
        self.rightBtn.setTitle("点击更多", for: .normal)
        self.rightBtn.setTitleColor(RGB(255, 151, 29), for: .normal)
        self.rightBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14)
        self.rightBtn.frame = FRAME_CGFloat(SCREEN_WIDTH - 90, 18, 90, 20)
        self.rightBtn.addTarget(self, action: #selector(moreAction(button:)), for: .touchUpInside)
        self.addSubview(self.rightBtn)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    @objc func moreAction(button:UIButton){
        delegate?.OthersListenReusableViewClick(id: self.id, name: self.leftLabel.text ?? "")
    }
}
